﻿using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ShoppingWebSite
{
    public partial class ShoppingSubmit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Session["UserId"] == null)
            {
                Response.Write("<script>alert('未登录，不可购买')</script>");
            }
            else
            {
                string sql = string.Format("insert [dbo].[Order] values({0},{1},'{2}',{3},'{4}')",
                        Session["UserId"].ToString(), Request["PId"].ToString(), DateTime.Now.ToString(), 2, "无");
                if (BLLAllOperation.BLL_GetExecuteNonQuery(sql))
                {
                    Response.Write("<script>alert('商品购买成功')</script>");
                }
                else
                {
                    Response.Write("<script>alert('商品购买失败')</script>");
                }
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("homeWeb.aspx");
        }
    }
}